{include file="public/header"}
<!-- 表单 -->
<style>
    .layui-form-label {
        width: 100px;
    }

    .layui-input-block {
        margin-left: 130px;
    }

    .layui-form-item {
        margin-right: 30%;
    }
</style>
</head>

<body>
    <div class="cBody">
        <form class="layui-form">
            <div class="layui-form-item">
                <label class="layui-form-label">标题名称</label>
                <div class="layui-input-block">
                    <input type="text" name="title" autocomplete="off" class="layui-input" value="{$find.title}">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">商品编号</label>
                <div class="layui-input-inline">
                    <input type="text" name="goods_sn" autocomplete="off" class="layui-input" value="{$find.goods_sn}">
                    <div class="layui-form-mid layui-word-aux">如果不填会自动生成</div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">商品类型</label>
                <div class="layui-input-inline">
                    <select name="cat_id" lay-filter="cat_id">
                        {volist name="cat" id="v"}
                        <option value="{$v.id}" {$find.cat_id==$v['id']?"selected":''}>{php}echo
                            str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;',$v['level']*1);{/php}{$v.name}</option>
                        {/volist}
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">缩略图</label>
                <div class="layui-input-inline" style="width: 120px;">
                    <div class="layui-upload-img">
                        <img src="{$find.thum}" id="fileslist">
                    </div>
                    <input type="hidden" name="thum" autocomplete="off" class="layui-input fileslist"
                        value="{$find.thum}">
                </div>
                <a href="javascript:;" class="layui-btn layui-btn-primary"
                    onclick="OpenView('{:url('Login/uploads')}?num=1&id=fileslist','文件上传')">文件上传</a>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">商品图片</label>
                <div class="layui-input-block">
                    <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                        <div class="layui-upload-list imglist" id="fileslist1">
                            {volist name="$find.goods_img_arr" id="v"}
                            <div class="img-card">
                                <div class="bgc-img"><a href="javascript:;" class="iconfont icon-shanchu"></a></div>
                                <img class="layui-upload-img" src="{$v}">
                            </div>
                            {/volist}
                        </div>
                        <div class="img-card">
                            <a href="javascript:;"
                                onclick="OpenView('{:url('Login/uploads')}?num=10&id=fileslist1','文件上传')"
                                class="layui-icon layui-icon-addition addimgs layui-upload-img"></a>
                        </div>
                    </blockquote>
                    <input type="hidden" name="goods_img" autocomplete="off" class="layui-input fileslist1"
                        value="{$find.goods_img}">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">商品原价</label>
                <div class="layui-input-inline">
                    <input type="tel" name="original_price" onkeyup="this.value=this.value.replace(/[^\d.]/g,'')"
                        onpaste="this.value=this.value.replace(/[^\d.]/g,'')" autocomplete="off" class="layui-input"
                        value="{$find.original_price}">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">商品售价</label>
                <div class="layui-input-inline">
                    <input type="tel" name="price" onkeyup="this.value=this.value.replace(/[^\d.]/g,'')"
                        onpaste="this.value=this.value.replace(/[^\d.]/g,'')" autocomplete="off" class="layui-input"
                        value="{$find.price}">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">商品库存</label>
                <div class="layui-input-inline">
                    <input type="tel" name="storage" autocomplete="off"
                        onkeyup="this.value=this.value.replace(/[^\d]/g,'')"
                        onpaste="this.value=this.value.replace(/[^\d]/g,'')" class="layui-input"
                        value="{$find.storage}">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">商品描述</label>
                <div class="layui-input-block">
                    <textarea name="remark" class="layui-textarea">{$find.remark}</textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">关键字</label>
                <div class="layui-input-block">
                    <input type="text" name="keywords" placeholder="每个关键字用英文逗号分隔," autocomplete="off"
                        class="layui-input" value="{$find.keywords}">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">显示/隐藏</label>
                <div class="layui-input-block">
                    <input type="radio" name="is_show" value="1" title="显示" {$find.is_show=="1" ?"checked":''}>
                    <input type="radio" name="is_show" value="0" title="隐藏" {$find.is_show=="0" ?"checked":''}>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">内容</label>
                <div class="layui-input-block">
                    <textarea name="content" class="layui-textarea" id="LAY_demo">{$find.content}</textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">是否推荐</label>
                <div class="layui-input-block">
                    <input type="radio" name="is_hot" value="1" title="是" {$find.is_hot=="1" ?"checked":''}>
                    <input type="radio" name="is_hot" value="0" title="否" {$find.is_hot=="0" ?"checked":''}>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">是否包邮</label>
                <div class="layui-input-block">
                    <input type="radio" name="is_pinkage" value="1" title="是" {$find.is_pinkage=="1" ?"checked":''}>
                    <input type="radio" name="is_pinkage" value="0" title="否" {$find.is_pinkage=="0" ?"checked":''}>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">虚拟销量</label>
                <div class="layui-input-inline">
                    <input type="tel" name="virtual_sales" autocomplete="off" class="layui-input"
                        onkeyup="this.value=this.value.replace(/[^\d]/g,'')"
                        onpaste="this.value=this.value.replace(/[^\d]/g,'')" value="{$find.virtual_sales}">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="submitBut">立即提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>


        <script>
            layui.use(['upload', 'form', 'layedit'], function () {
                var form = layui.form;
                var upload = layui.upload;
                var layer = layui.layer;
                var layedit = layui.layedit;
                form.render();
                layedit.set({
                    uploadImage: {
                        url: '{:url("Login/uploads")}',   //接口url
                    }
                });
                //自定义工具栏
                var index = layedit.build('LAY_demo', {
                    tool: [
                        'strong', //加粗
                        'italic', //斜体
                        'underline', //下划线
                        'del', //删除线
                        '|', //分割线
                        'left', //左对齐
                        'center', //居中
                        'right', //右对齐
                        'link', //超链接
                        'unlink', //清除链接
                        'image' //插入图片
                    ]
                });
                form.verify({
                    content: function (value) {
                        return layedit.sync(index);
                    }
                });
                //监听提交
                form.on('submit(submitBut)', function (data) {
                    data.field.content = layedit.getContent(index);
                    ajax_submit(data.field, '', 'demo');
                    return false;
                });
            });
            //多文件选择
            $('body').delegate('.img-card .bgc-img a', 'click', function () {
                //获取文件路径
                var src = $(this).parent().parent().children('img').attr('src');
                //获取ID
                var id = $(this).parent().parent().parent().attr('id');
                //获取input内容
                var val = $('.' + id).val();
                console.log(val);
                //转为数组
                var arrval = val.split(',');
                var con = [];
                $.each(arrval, function (v, i) {
                    if (i != src) {
                        con.push(i);
                    }
                    console.log(i);
                });
                console.log(con);
                $(this).parent().parent().remove();
                $('.' + id).val(con.toString());
            });
        </script>
    </div>
</body>
{include file="public/footer"}